import {
  AppSubAnalysisByTenantMap,
  AppSubAnalysisByTenantReqDto,
  AppSubAnalysisInTotalReq,
  AppSubAnalysisInTotalResp,
  AppSubProportionReq,
  AppSubProportionResp,
  AppSubRateMap,
  AppSubRateReq,
} from './model/appSubscriptionModel';
import { operationHttp } from '/@/utils/http/axios';

enum Api {
  GET_APP_SUBSCRIPTION_BY_TENANT = '/v1/appRenewOrUnsub/appAnalysisByTenant',
  GET_APP_SUBSCRIPTION_PROPORTION = '/v1/appRenewOrUnsub/appProportion',
  GET_APP_SUB_NUM = '/v1/appRenewOrUnsub/getAppStatistic',
  GET_APP_SUB_RATE = '/v1/appRenewOrUnsub/getAppRenewOrUnsubRate',
}

export const getAppSubscriptionByTenant = (params: AppSubAnalysisByTenantReqDto) => {
  // 获取租户应用套餐订阅情况
  return operationHttp.post<AppSubAnalysisByTenantMap[]>({
    url: Api.GET_APP_SUBSCRIPTION_BY_TENANT,
    params,
  });
};

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const getAppSubscriptionProportion = (params: AppSubProportionReq) => {
  // 获取应用续订/退订比例
  return operationHttp.get<AppSubProportionResp>({
    url: Api.GET_APP_SUBSCRIPTION_PROPORTION,
    params,
  });
};

export const getAppSubNum = (params: AppSubAnalysisInTotalReq) => {
  // 获取应用续订/退订数（汇总） - 请求参数：', params);
  return operationHttp.get<AppSubAnalysisInTotalResp>({
    url: Api.GET_APP_SUB_NUM,
    params,
  });
};

export const getAppSubRate = (params: AppSubRateReq) => {
  // 获取应用续订/退订率
  return operationHttp.post<AppSubRateMap[]>({
    url: Api.GET_APP_SUB_RATE,
    params,
  });
};
